define(function(require, exports){

	// 列表
	exports.onMain = function(boot, data, app){
		if (!app.routerValid('monitor.listAlarms')) {
			return;
		}

		var title = LANG('智能监控列表')

		var cont = app.getContainer({
			scenes: 'main',
			full: false,
			sitee: false,
			setup_btn: false,
			title: title
		});

		app.core.get('SYS_PLATFORM').setPlatform(title);

		cont.createBusiness(data.name  + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': 'admin'
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});

		cont.createBusiness(data.name, 'admin/smartMonitor/action/list.list', {
		}, function(mod){
			mod.reload();
		});
	}

	// 编辑
	exports.onEdit = function(boot, data, app){
		if (!app.routerValid('monitor.addAlarm')) {
			return;
		}
		var id = +data.param;
		var title = id ? LANG('编辑监控设置') : LANG('新建监控设置');

		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitee: false,
			setup_btn: false,
			title: title
		});

		app.core.get('SYS_PLATFORM').setPlatform(title);

		con.createBusiness(data.name  + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': ''
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});

		con.createBusiness(data.name, 'admin/smartMonitor/action/edit.edit', {
		}, function(mod, created){
			if(created){
				mod.reset();
			}
			if(id){
				mod.load(id);
			}
		});
	}

	// 另存为
	exports.onSaveas = function(boot, data, app){
		if (!app.routerValid('monitor.addAlarm')) {
			return;
		}

		var id = +data.param;
		var title = LANG('另存为监控设置');

		var cont = app.getContainer({
			scenes: 'main',
			full: false,
			sitee: false,
			setup_btn: false,
			title: title
		});

		app.core.get('SYS_PLATFORM').setPlatform(title);

		cont.createBusiness(data.name, 'admin/smartMonitor/action/edit.edit', {
		}, function(mod){
			if(id){
				mod.load(id, 'saveas');
			}else{
				mod.reset();
			}
		});
	}

	// 查看
	exports.onCheck = function(boot, data, app){
		if (!app.routerValid('monitor.infoAlarm')) {
			return;
		}

		var id = +data.param;
		var title = LANG('查看监控设置');

		var cont = app.getContainer({
			scenes: 'main',
			full: false,
			sitee: false,
			setup_btn: false,
			title: title
		});

		app.core.get('SYS_PLATFORM').setPlatform(title);

		cont.createBusiness(data.name, 'admin/smartMonitor/action/edit.edit', {
			'readonly': true
		}, function(mod){
			if(id){
				mod.load(id);
			}
		});
	}
});